import { Injectable } from '@angular/core';
import {Observable} from "rxjs/Observable";
import {MsgResult} from "../../../../models/msg-result";
import {DamAPI} from "../../peach-constants";
import {RequestUtil} from "../../../../util/request-util";

@Injectable()
export class AirQualityDataService {

  constructor(
    private requestUtil: RequestUtil
  ) { }

  //不同用户不同站点
  getUserSiteData():Observable<MsgResult>{
    return this.requestUtil.get(DamAPI.getUserSite);
  }

  getAirQualityData(obj):Observable<MsgResult>{
    let params;
    if(obj.pointType == "smallAirSite"){
      params = "format=json&pointType="+obj.pointType+"&dataType="+obj.dataType+"&dataCalculateType="+obj.dataCalculateType+"&startTime="+obj.startTime+"&endTime="+obj.endTime+"&pointCodes="+obj.pointCode;
    }else{
      params = "format=json&pointType="+obj.pointType+"&dataType="+obj.dataType+"&dataCalculateType="+obj.dataCalculateType+"&startTime="+obj.startTime+"&endTime="+obj.endTime;
    }
    return this.requestUtil.get(DamAPI.airQualityData,params);
  }
}
